package edu.cicese.alz.swing;

import javax.swing.JPanel;

/**
 * Created by: Eduardo Quintana Contreras
 * Date: 24/06/12
 * Time: 02:01 PM
 */
public class JScrollablePane extends JPanel /*implements Scrollable, SwingConstants */{

	/*public JScrollablePane(LayoutManager layoutManager) {
		super(layoutManager);
	}


	@Override
	public Dimension getPreferredScrollableViewportSize() {
		return getPreferredSize();
	}

	@Override
	public int getScrollableUnitIncrement(Rectangle visibleRect, int orientation, int direction) {
		switch(orientation)
		{
			case SwingConstants.HORIZONTAL:
				return getScrollableIncrement(horizontalUnit, visible.width);
			case SwingConstants.VERTICAL:
				return getScrollableIncrement(verticalUnit, visible.height);
			default:
				throw new IllegalArgumentException("Invalid orientation: " + orientation);
		}
	}

	@Override
	public int getScrollableBlockIncrement(Rectangle visibleRect, int orientation, int direction) {
		switch(orientation)
		{
			case SwingConstants.HORIZONTAL:
				return getScrollableIncrement(horizontalBlock, visible.width);
			case SwingConstants.VERTICAL:
				return getScrollableIncrement(verticalBlock, visible.height);
			default:
				throw new IllegalArgumentException("Invalid orientation: " + orientation);
		}
	}

	protected int getScrollableIncrement(IncrementInfo info, int distance)
	{
		if (info.getIncrement() == IncrementType.PIXELS)
			return info.getAmount();
		else
			return distance * info.getAmount() / 100;
	}

	@Override
	public boolean getScrollableTracksViewportWidth() {
		if (scrollableWidth == ScrollableSizeHint.NONE)
			return false;

		if (scrollableWidth == ScrollableSizeHint.FIT)
			return true;

		//  STRETCH sizing, use the greater of the panel or viewport width

		if (getParent() instanceof JViewport)
		{
		    return (((JViewport)getParent()).getWidth() > getPreferredSize().width);
		}

		return false;
	}

	@Override
	public boolean getScrollableTracksViewportHeight() {
		if (scrollableHeight == ScrollableSizeHint.NONE)
			return false;

		if (scrollableHeight == ScrollableSizeHint.FIT)
			return true;

		//  STRETCH sizing, use the greater of the panel or viewport height


		if (getParent() instanceof JViewport)
		{
		    return (((JViewport)getParent()).getHeight() > getPreferredSize().height);
		}

		return false;
	}*/
}